function setDisabled(el, value) {
  el.disabled = value;
  el.ariaDisabled = value ? "true" : null;
  if (value) {
    el.classList.add("is-disabled");
  } else {
    el.classList.remove("is-disabled");
  }
}

export default {
  bind(el, binding, vnode) {
    el.addEventListener("click", (evt) => {
      if (el.ariaDisabled) {
        evt.preventDefault();
      } else {
        setDisabled(el, true);
        setTimeout(() => {
          setDisabled(el, false);
        }, binding.value ?? 4500);
      }
    });
  },
};
